package client

import (
	"context"
	"github.com/golang/protobuf/ptypes/empty"
	"github.com/micro/go-micro/v2/client"
	"github.com/micro/go-micro/v2/client/grpc"
	"kop/framework/wrapper"
	"kop/pb/service"
)

var ServerService service.ServerService

func init() {

	var c = grpc.NewClient(client.Wrap(wrapper.ClientLogWrapper))
	_ = c.Init()

	//s.Init(test.Flags()...)

	ServerService = service.NewServerService("go.micro.srv.configuration", c)
}

func GetServers() ([]*service.Server, error) {

	if resp, err := ServerService.GetServers(context.Background(), &empty.Empty{}); err != nil {

		return nil, err
	} else {

		return resp.Servers, nil
	}
}
